## This file makes the t-SNE plot for the voting example

load("vote/out/vote_out_pois.rda")

# Aggregate
# see documentation for BRS::agg_BRS
set.seed(123)
agg <- agg_BRS(fit=out, X=X, Y=Y, maxLen=3, split = F, simplify = T, 
               oppmat=oppmat, oppind=oppind, minProp = .05)

# plot
png("figures/vote_tsne.png", width = 4, height = 4, units = 'in', res = 300)
set.seed(6)  # chosen for aesthetics
plot_tsne(X, Y, agg, max_iter = 1000, pointSize = .75, symb = c(20, 4),
          caseColors=prettyGraphs::add.alpha(RColorBrewer::brewer.pal(8, "RdYlGn")[c(6,1)], alpha=1),
          highlight=NULL)
          #highlight = 2)
          # to see which points are covered by the second rule of agg 
          # (i.e., "depression_lowmed" and "polint_high"), set highlight=2
          # In the paper, we do this to identify the points covered by the rule, 
          # then encircle them (on a graph with no highlighting) with photo-editing software
dev.off()


